<template>
	<view class="box">
		<plantView :width="boxWidth" :height="boxHeight" :stick="1" ref="plantView"></plantView>
	</view>
</template>


<script>
	import plantView from '@/libs/components/plant/plant-view.vue'
	export default {
		components:{plantView},
		data() {
			return {
				boxWidth:0,
				boxHeight:0,
				data:[]
			};
		},
		created(){
			uni.getSystemInfo({
				success: (res) => {
					this.boxWidth = res.windowWidth; // 画布宽度
					this.boxHeight = res.windowHeight; // 画布高度
				}
			});
			
		},
		mounted(){
			this.getData()
		},
		methods:{
			getData() {
				const colors = ['#ffffff','#9485D8','#58B4AC']
				uni.request({
					url: 'https://mock.apifox.cn/m1/3009310-0-default/plant/list',
					method: 'GET',
					success: (res) => {
						res.data.forEach((da,index) => {
							da.text = da.name;
							da.color = colors[index%3]
						})
						this.$refs.plantView.setData(res.data)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box{
		width: 100%;
		height: 100%;
	}
</style>
